
#T1.df<-read.csv('/Users/me/PycharmProjects/DGL/data/锦州毒2.csv',header = FALSE)


#需要把每个手机号看成一个item, 之前的方式只是个简单的方式
T2.df<-read.transactions(file="/Users/me/PycharmProjects/DGL/data/锦州毒2.csv", format="basket",sep=",")


summary(T2.df)


#参考：https://blog.csdn.net/gjwang1983/article/details/45015203
#https://blog.csdn.net/jiabiao1602/article/details/42113687?utm_source=blogxgwz7

#T2.ar<- apriori(T2.df, parameter = list(support=0.00024, confidence=0.001, lift=1000,minlen=2))
T2.ar<- apriori(T2.df, parameter = list(support=0.000024, confidence=0.00001,minlen=2))

ordered_groceryrules <- sort(T2.ar, by="lift")

inspect(T2.ar[1:5])

plot(density(size(T2.ar)))

plot(ordered_groceryrules, method = "graph")

yogurtrules <- subset(ordered_groceryrules, rhs %in% c("15084153000","13897884122"))

plot(yogurtrules, method="graph", control=list(k=6))

plot(yogurtrules, method="paracoord", control=list(k=6))


#Error in hclust(dist(s_clust)) : must have n >= 2 objects to cluster
plot(T2.ar, method="grouped", control=list(k=6))

plot(T2.ar, method="graph", control=list(k=6))

plot(T2.ar, method="paracoord", control=list(k=6))


write.csv(as(T1.ar, "data.frame"), "T1Ar.csv")
